package com.mnkr.bean;

import java.io.Serializable;

import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.application.ViewExpiredException;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

@ManagedBean(name="monkarTest")
public class MonkarTest implements Serializable {

	
	  /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String actionThrowNullPointer() {  
	        throw new NullPointerException("Horrrroooorrrrr !!!");  
	}
	
	public String statusTest() {  
        for(long i= 0; i<=9999999999L; i++){
        	
        }
        System.out.println("termino prueba status");
        return "success";
	}
	  
	  public String actionWrappedException() {  
	        Throwable t = new IllegalStateException("This is wrapped illegal state exception!");  
	        throw new FacesException(t);  
	    }
	  
//	  mensajes
	  public void addInfo(ActionEvent actionEvent) {  
	        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Sample info message", "PrimeFaces rocks!"));  
	  }  
	  
	  public void addWarn(ActionEvent actionEvent) {
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,"Sample warn message", "Watch out for PrimeFaces!"));
		}

		public void addError(ActionEvent actionEvent) {
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Sample error message", "PrimeFaces makes no mistakes"));
		}

		public void addFatal(ActionEvent actionEvent) {
			statusTest();
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL,"Sample fatal message", "Fatal Error in System"));
		}
		
		    
		    
}
